﻿<UserControl x:Class="MVVM.MainView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ic="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:local="clr-namespace:MVVM"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:s="NavigationPane"
             d:DesignHeight="480"
             d:DesignWidth="640"
             mc:Ignorable="d">
    <UserControl.Resources>
        <local:MainViewModel x:Key="MainViewModelDataSource" />
    </UserControl.Resources>

    <DockPanel x:Name="LayoutRoot"
               d:DataContext="{d:DesignData /SampleData/MainViewModelSampleData.xaml}"
               DataContext="{Binding Source={StaticResource MainViewModelDataSource}}">
        <s:NavigationPane x:Name="navigationPane"
                          Width="200"
                          HorizontalAlignment="Left">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:Interaction.Behaviors>
                        <ic:ConditionBehavior>
                            <ic:ConditionalExpression>
                                <ic:ComparisonCondition LeftOperand="{Binding SelectedIndex, ElementName=navigationPane}" RightOperand="0" />
                            </ic:ConditionalExpression>
                        </ic:ConditionBehavior>
                    </i:Interaction.Behaviors>
                    <ic:CallMethodAction MethodName="ViewModelMethod" TargetObject="{Binding}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <s:NavigationPaneItem Header="Update value on select">
                <Grid />
            </s:NavigationPaneItem>
            <s:NavigationPaneItem Header="No Command" />
        </s:NavigationPane>
        <Grid>
            <TextBlock HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Text="{Binding ViewModelProperty}" />
            <Button Height="41"
                    Margin="0,125,0,0"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Content="Update Value">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ic:CallMethodAction MethodName="ViewModelMethod" TargetObject="{Binding}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </Grid>
    </DockPanel>
</UserControl>